<?php

/**
 * Description of PersonPersonClass
 *
 * @author adhamhelal
 */
class OrgWorkPanel extends Qpanel {
	protected $mctAddress;

        //Controls
        protected $txtWorkPhone;
        protected $txtWorkPhone2;
        protected $txtWorkPhone3;
        protected $txtWorkFax;
        protected $txtWorkMobile;
        protected $txtWorkMobile2;
        protected $txtWorkEmail;
        protected $txtWorkEmail2;
        protected $txtWebsite;

        protected $strTemplate;

        public function __construct($objParentObject, $mctAddress, $strControlId = null) {
                // Call the Parent
                try {
                        parent::__construct($objParentObject, $strControlId);
                } catch (QCallerException $objExc) {
                        $objExc->IncrementOffset();
                        throw $objExc;
                }

                // Setup Template
                $this->strTemplate = __DOCROOT__.__PERSON__ .  '/tpl/qpanel.tpl.php';
                // Set the Person Meta Conrol
                $this->mctAddress = $mctAddress;

                    // Call MetaControl's methods to create qcontrols
                $this->txtWorkPhone = $this->mctAddress->txtWorkPhone_Create();
                $this->txtWorkPhone->SetParentControl($this);

                $this->txtWorkPhone2 = $this->mctAddress->txtWorkPhone2_Create();
                $this->txtWorkPhone2->SetParentControl($this);

                $this->txtWorkPhone3 = $this->mctAddress->txtWorkPhone3_Create();
                $this->txtWorkPhone3->SetParentControl($this);

                $this->txtWorkMobile = $this->mctAddress->txtWorkMobile_Create();
                $this->txtWorkMobile->SetParentControl($this);

                $this->txtWorkMobile2 = $this->mctAddress->txtWorkMobile2_Create();
                $this->txtWorkMobile2->SetParentControl($this);

                $this->txtWorkFax = $this->mctAddress->txtWorkFax_Create();
                $this->txtWorkFax->SetParentControl($this);

                $this->txtWorkEmail = $this->mctAddress->txtWorkEmail_Create();
                $this->txtWorkEmail->SetParentControl($this);

                $this->txtWorkEmail2   = $this->mctAddress->txtWorkEmail2_Create();
                $this->txtWorkEmail2->SetParentControl($this);

                $this->txtWebsite = $this->mctAddress->txtWebsite_Create();
                $this->txtWebsite->SetParentControl($this);
        }

 public function Validate() {
        $Error = false;
        $blnToReturn = true;

        if ( ValidateNumberCtl($this->txtWorkPhone) )   $Error=true;
        if ( ValidateNumberCtl($this->txtWorkPhone2) )  $Error=true;
        if ( ValidateNumberCtl($this->txtWorkPhone3) ) $Error=true;
        if ( ValidateNumberCtl($this->txtWorkMobile) )  $Error=true;
        if ( ValidateNumberCtl($this->txtWorkMobile2) ) $Error=true;
        if ( ValidateNumberCtl($this->txtWorkFax) ) $Error=true;
        if ( ValidateEmailCtl($this->txtWorkEmail) )   $Error=true;
        if ( ValidateEmailCtl($this->txtWorkEmail2) )   $Error=true;

        $blnFocused = false;
        foreach ($this->GetChildControls()  as $objControl) {
              if ( !is_null($objControl->Warning) )  {
                    if (!$blnFocused) {
                            $objControl->Focus();
                            $blnFocused = true;
                    }
                    $objControl->Blink();
              }
        }
        return $Error;
    }





}
?>

